begin
  require 'main/init'
rescue LoadError
  require 'src/main/ruby/main/init'
end
require 'lib/configuration'

module Testing

  def print_info
    puts "The Ruby VM is: #{RUBY_DESCRIPTION}"
    puts 'My Loadpath is:'
    puts $:
    puts 'My classpath is:'
    puts $CLASSPATH
    puts 'Classpath empty!' if (!$CLASSPATH || $CLASSPATH.size == 0)
    require 'rubygems'
    require 'rubygems/command_manager'
    ['GEM_HOME', 'GEM_PATH'].each { |var| puts "#{var}:"; puts ENV[var] || 'NULL' }
    puts 'RUBYGEMS_DIR:'
    puts Gem::RUBYGEMS_DIR
    puts 'List of installed gems:'
    Gem::CommandManager.instance.run('list')
    require 'pathname'
    puts "CWD: #{Pathname('.').realpath}"
    puts "Db4o: #{com.db4o.Db4oEmbedded}"
  end

  def db4o_session_init
    ENV['MINERSTART'] = 'ruby'
    java_import [de.recipeminer.persistence.Db4oContainer,
                 de.recipeminer.crawling.chefkoch.ChefkochCrawlingState,
                 de.recipeminer.crawling.chefkoch.ChefkochJsonRecipe]
    db4o = Db4oContainer::DEFAULT
    session = db4o.start_session
    state = ChefkochCrawlingState.instance
    recipes = session.query(ChefkochJsonRecipe.java_class)
    puts "State knows of #{state.crawled_count} recipes"
    puts "There are #{recipes.size} recipes in the db4o"
  end

  def save_to_file(object, rel_path)
    File.open(rel_path, 'w') do |f|
      f.puts object.to_s
    end
  end


end